package com.fly.trading.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.fly.trading.dao.TradingUserRepository;
import com.fly.trading.entity.TradingUser;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
public class RestUserController
{
    @Autowired
    TradingUserRepository tradingUserRepository;
    
    @GetMapping(path = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
    public Flux<TradingUser> listUsers()
    {
        return tradingUserRepository.findAll();
    }
    
    @GetMapping(path = "/users/{username}", produces = MediaType.APPLICATION_JSON_VALUE)
    public Mono<TradingUser> showUsers(@PathVariable String username)
    {
        return tradingUserRepository.findByUserName(username);
    }
}